package com.multi.tool.concurrent.jol;

import org.openjdk.jol.info.ClassLayout;
import org.openjdk.jol.info.GraphLayout;

/**
 * @author zhengpeng.wang
 */
public class JOLDemo2 {

    public static void main(String[] args) {
        Stu stu = new Stu();
        System.out.println(ClassLayout.parseInstance(stu).toPrintable());
        System.out.println("size : " + GraphLayout.parseInstance(stu).totalSize());

//        -XX:UseBiasedLocking : 是否打开偏向锁。默认不打开的。
//        -XX:BiasedLockingStartupDelay  默认是4秒。
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        Stu stu1 = new Stu();
//        stu1.setName("wzpwzp");
//        stu1.setAge(19);
        System.out.println(ClassLayout.parseInstance(stu1).toPrintable());
        //获取对象总大小
        System.out.println("size : " + GraphLayout.parseInstance(stu1).totalSize());

//        synchronized (o){
//            System.out.println(ClassLayout.parseInstance(o).toPrintable());
//        }
    }
}
